#include "SpriteSurface.h"

int SpriteSurface::LoadResource()
{
	if(this->ReadInfo())
		return 1;
		// create surface
	HRESULT result =  d3ddev->CreateOffscreenPlainSurface(
		info.Width, // width
		info.Height, // height
		D3DFMT_X8R8G8B8,
		D3DPOOL_DEFAULT,
		&surface,
		NULL);
	if(result)
		return 1;

	// Set default location
	this->spriteInfo.x = SPRITE_X_SURFACE;
	this->spriteInfo.y = SPRITE_Y_SURFACE;

	result = D3DXLoadSurfaceFromFile(surface, NULL, NULL, this->fileName, NULL, D3DX_DEFAULT, 0, NULL);
	if(result)
		return 1;
	return 0;
}

SpriteSurface::SpriteSurface(LPWSTR filename, LPDIRECT3DDEVICE9 d3ddev) : ISprite(filename,d3ddev, D3DCOLOR_XRGB(255,0,255))
{
	surface = NULL;
}

SpriteSurface::SpriteSurface(void)
{
	surface = NULL;
}


SpriteSurface::~SpriteSurface(void)
{
	surface = NULL;
}
